const fs = require("fs");
const path = require("path");
const router = require('express').Router()
let json = JSON.parse(fs.readFileSync(path.join(__dirname, '../', './examples/细分类目.json'), {encoding: "utf8"}))
let cacheController = require('../controller/cacheController/index')
let logController = require('../controller/logController/index')

// 空url路由
router.get('/', cacheController.getHTMLtoCache, cacheController.saveHTMLtoCache('news'))
// 测试路由
router.get('/test', (req, res, next) => {

    res.render('news/common/res.html', {originalUrl: req.originalUrl})
})
// 商品列表
router.get('/goods', (req, res) => {
    res.render('news/tuwen/list.html')
})
// 商品路由
router.get('/goods/:id', (req, res) => {
    res.render('news/tuwen/detail.html')
})

router.get('/news', (req, res) => {
    res.render('news/chunwenzi/list.html')
})
router.get('/news/:id', (req, res) => {
    res.render('news/chunwenzi/detail.html')
})
// 一级url随机
router.get('/:keyword',cacheController.getHTMLtoCache, cacheController.saveHTMLtoCache('news/tuwen/list.html'))
// 二级url随机
router.get('/:listid/:itemid', cacheController.getHTMLtoCache, cacheController.saveHTMLtoCache())

module.exports = router